package program

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url '/api/programs'
    }
    response {
        status 200
        body("""
            {
            "content": [
              {
                "id": 1,
                "category": "付费",
              }
            ],
            "totalPages": 1,
            "totalElements": 1
            }
        """)
        bodyMatchers {
            jsonPath('$.[*]', byType())
            jsonPath('$.content.[*].id', byRegex(number()))
            jsonPath('$.content.[*].category', byRegex(onlyAlphaUnicode()))
            jsonPath('$.totalPages', byRegex(number()))
            jsonPath('$.totalElements', byRegex(number()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}